package com.hioove.core.reflect;

import com.hioove.core.model.base.config.MethodSupport;
import com.hioove.core.util.ClassUtils;

import java.util.List;
import java.util.Optional;

public abstract class AopProxy implements Proxy {
    private static String CGLIB_PROXY = "com.hioove.core.aop.AopCglibProxy";

    public abstract AopProxy setPointcut(List<MethodSupport> pointcut);

    public abstract AopProxy setBefore(List<MethodSupport> before);

    public abstract AopProxy setAfter(List<MethodSupport> after);

    public abstract AopProxy setAfterReturning(List<MethodSupport> afterReturning);

    public abstract AopProxy setAfterThrowing(List<MethodSupport> afterThrowing);

    public abstract AopProxy setAround(List<MethodSupport> around);

    public static AopProxy getInstance() {
        // 如果加载后就不会加载
        Optional<Object> obj = Optional.ofNullable(ClassUtils.createObj(CGLIB_PROXY));
        return (AopProxy) obj.get();
    }
}
